<?php
class xitongControl extends Control{
	public function index(){
		$this->display();
	}
  
	
	//添加配置项配置项显示
      public function add_type_show(){
      	$this->display();
      }
    	//添加配置项配执行
     public function add_type(){
     	$db=M('config_type');
     	if($db->add()){
     		$this->success('添加配置项成功');
     		}else{
     			$this->error('添加配置项失败');
     		}
     }
      //配置组分类
      public function type(){
     	$db=M('config_type');
     	$dab=$db->all();
        $this->assign("type", $dab);
         $this->display();
     }
     
    //配置项查看
     public function add_config_show(){
     	$db=M('config_type');
     	$dd=$db->all();
     
     	$this->assign('config_Show',$dd);
     	$this->display();
     }
    //写入配置项
    public function add_config(){
    	$db=M('config');
    	if($db->add()){
    		$this->success('添加配置项成功');
    		}else{
    			$this->error('添加失败');
    		}
    }
    
    //配置项列表
    public function config(){
    	$db=K('configview');
    	$sql=$db->order("hd_config.id asc")->all();
    	
    	$this->assign('type',$sql);
    	$this->display();
    }
     //删除配置项
    public function del_config(){
    	$db=K('configview');
    	$catid=$_GET['catid'];
    	if($db->del($catid)){
    		$this->success('删除成功');
    	}else{
    		$this->error("删除失败");
    	}
    	p($catid);
    }

   //编辑配置项
   public function edit_config(){
   	
   	$db=K('configview');
   	
   	$tid=$_GET['catid'];
    $sql=$db->where("id='$tid'")->all();
   
    $this->assign('config_show',$sql);
     $this->display();
   }
   //更新配置项
   public function update_config(){
    $db=K('configview');
   	$id=$_POST['id'];
   if($db->where("id='$id'")->update()){
   		
   		$this->success('更新成功');
   		
   	}else{
   	
   		$this->error('更新失败');
   	}
   }
 
     //基本设置
   public function setconfig() {
        $db = M("config");   
        $tid = $db->group("tid")->field("tid")->all();
		$config = array();
        if(!empty($tid)){
		foreach ($tid as $t) {
        $data = $db->where("tid={$t['tid']}")->all();
        $data = format_config($data);
            $config[$t['tid']] = $data;
       }
        $this->assign("config",$config);
        $this->display();	
		}else{
			echo "请添加配置项";
		}
		
    }
 
   //修改配置项
   public function peiziup(){
   	$a=$_POST;
   foreach($a as $k=>$v){
   	 	$db=M("config");
   	if($db->where("pid=$pid")->update()){
   		$this->success('更新成功');
   	}else{
   		$this->error('更新失败');
   	}
   		
   	}
   	
  
   }



}


?>